Repository navigation
fix(pm-stack): claimant session fetch must prove completeness — escalating limit, fail closed (#4757) - #6756
Conversation
…ating limit, fail closed (#4757) GET /api/session truncates at 50 by default; poll.py treated that page as the whole list, understating live roots ~150x (true count 7,583 vs the 50-row page) and making bound sessions outside the page read as gone. The endpoint honours limit but not offset (an offset page repeats the first page — verified live), so fetch_sessions now reads with an escalating limit (1000, 10000, 100000) and accepts the first read that returns below its limit as complete by construction; a read at its limit every time, or any failed/non-list read, fails closed to None (cap_room null). claimant.py supervision_step gets the same list-verb correction as poll.py in #6609 (the deployed binary rejects list --worker) and reads rich rows (progress.session_id) with a flattened-row fallback. Five fetch-layer tests stub _server_get: short read, escalation, exact-limit escalation, failed read fail-closed, at-every-limit fail-closed. The 36 pinned tests are untouched and pass; live: fetch_sessions returns all 9,601 sessions in 0.4s, summarize_cap reports 7,583 live / 15 active / room 21.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
Fixes #4757.
Problem (triage-confirmed live this shift, Lane W)
GET /api/sessiontruncates at 50 entries by default. poll.py'sfetch_sessions()treated that page as the complete list — the claimant's cap accounting and stuck-bound session lookup both ran over a 50-row window. Live numbers at fix time: the server holds 9,601 sessions / 7,583 roots; the truncated page reported ~50 live roots. Any active root outside the newest-50 page was invisible to the cap count (room overstated → launch into a saturated fleet), and a bound session outside the page read as missing ("gone") to stuck-bound classification.What the live server actually does (probed this shift)
?limit=1000→ 1000 rows (limit honoured).offsetis NOT honoured:?limit=1000&offset=1000returns the same first 1000 ids as offset 0. (The first implementation paginated with offset behind a non-advancement guard — it correctly failed closed toNoneon the live server, which is how this was caught. That design is replaced, not shipped.)?limit=10000read returns all 9,601 rows in ~0.9s.Change
poll.pyfetch_sessions(): escalating-limit read —limit1000 → 10000 → 100000; the first read whose count is below its limit is the complete list by construction. A read at its limit every time, or any failed/non-list read, returnsNone(fail closed →cap_room: null, launch nothing) rather than certifying a possibly-truncated list.claimant.pysupervision_step: the same list-verb correction poll.py got in opencode-claimant(poll/claimant): snapshot rewrite dropped poll.py's test-pinned cap API (36/36 tests error) and inverted cap_room — idle reads as saturated, busy launches unbounded #6609 — the deployed repo-queue binary rejectslist --worker, so supervision's row fetch silently fetched nothing; it now callslist --queue <q> --status claimedand reads rich rows (progress.session_id) with a flattened-row fallback. (Supervision's session existence check was already per-idGET /api/session/<id>and is unchanged.)test_poll.pystubbing_server_get(short read complete in one call; escalation finds the whole list; count exactly at a limit escalates; failed read fails closed; count at every limit fails closed). The 36 pinned tests are untouched.Verification
python3 -m unittest pm-stack/opencode-claimant/test_poll.py— 41/41 OK.fetch_sessions()returns all 9,601 sessions in 0.4s;summarize_capover the complete list reports 7,583 live roots / 15 active / cap_room 21 (the truncated page had reported ~50 live roots).Filed and worked in queue fallback mode (queue backend down, code#6619) by Lane W. One heartbeat comment on #4757 was posted via the developing.today GitHub App after the user token hit a secondary rate limit.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.